<?php

function LoadConfig()
{
    $fichier = 'config.txt';
    if (file_exists('config.txt'))
    {
        $donnee = file($fichier) or die ("Impossible de lire le fichier: ".$fichier);
        
        if (is_array($donnee))
        {
            foreach ($donnee as $line)
            {
                $setting_value = explode('=', $line);
                if ( strtolower($setting_value[0]) == 'servername')
                {
                    $settings['servername'] = trim($setting_value[1]);
                }
                if ( strtolower($setting_value[0]) == 'username')
                {
                    $settings['username'] = trim($setting_value[1]);
                }
                if ( strtolower($setting_value[0]) == 'password')
                {
                    $settings['password'] = trim($setting_value[1]);
                }
                if ( strtolower($setting_value[0]) == 'portalbaseurl')
                {
                    $settings['portalbaseurl'] = trim($setting_value[1]);
                }
                if ( strtolower($setting_value[0]) == 'database')
                {
                    $settings['database'] = trim($setting_value[1]);
                }
            }
        }
    }
    return ($settings);
}
?>
